#ifndef __Skeleton_H__
#define __Skeleton_H__


#include "video/Animation.h"
#include "video/Bone.h"
#include "video/RelCounted.h"
#include <string>
#include <map>

namespace KEngine
{

class SkeletalAnimation;

class Skeleton :  public RefCounted
{
public:
	typedef std::map<std::string, SkeletalAnimation*> AnimationMap;
	typedef AnimationMap::iterator AnimationIterator;
	typedef AnimationMap::const_iterator AnimationConstIterator;
	typedef AnimationMap::value_type AnimationValue;

public:
	Skeleton();
	virtual ~Skeleton();

	void	addBone(Bone* bone);
	int		getBoneID(const std::string& name);
	Bone*	getBone(int id);
	Bone*	getBone(const std::string& name);
	int		getBoneCount();

	const char* getName();
	
	bool	load(const char* filename);
	void	optimize();
	void	update(SkeletalAnimation* sa, const AnimationState& as);

	// skeleton animation set
	bool	createAnimation(const char* filename, const std::string& name);
	SkeletalAnimation* getAnimation(const std::string& name);

protected:
	std::string				mName;

	BoneList				mBoneList;
	Bone*					mBoneTree;

	AnimationMap			mAnimationList;
};

}

#endif 